﻿#ifndef __GAF_RESOURCE_H__
#define __GAF_RESOURCE_H__

namespace GAF
{
	//struct ActionIntent;
		struct ZoomIntent;
	//class Player
		//class Animation -* Runnable
			//class Action
				class ZoomAction;
}
typedef GAF::ZoomIntent			GAF_SZoomIntent;
typedef GAF::ZoomAction			GAF_CZoomAction;

#include "GAF_Action.h"

namespace GAF
{
	struct ZoomIntent : ActionIntent
	{
		/// 整体缩放开始值
		double		dStartZoom;
		/// 整体缩放结束值
		double		dEndZoom;

		/// X轴缩放开始值
		double		dStartZoomX;
		/// X轴缩放结束值
		double		dEndZoomX;

		/// Y轴缩放开始值
		double		dStartZoomY;
		/// Y轴缩放结束值
		double		dEndZoomY;

		/// 运行模式
		ActionMode	amMode;
		/// 缩放所需时间
		TimeTicks	ttRun;
		/// 缩放次数
		UINT		nTimes;

		void Reset()
		{
			dStartZoom = 0.0;
			dEndZoom = 0.0;
			
			dStartZoomX = 0.0;
			dEndZoomX = 0.0;

			dStartZoomY = 0.0;
			dEndZoomY = 0.0;

			amMode = ACTION_AGAIN;
			ttRun = 5000;
			nTimes = 0;
		}
	};

	/// 缩放动作类
	class ZoomAction : public Action
	{
	public:
		ZoomAction();
		~ZoomAction();

	public:
		void		SetIntent(ActionIntent* pIntent);
		void		ZoomTo(double dTargetZoom);

	protected:
		bool		OnPlay(Bundle* pParam);
		bool		OnUpdate(TimeTicks ttUsed);
		bool		OnStop();

	private:
		int		UpdateZoom(TimeTicks ttUsed,
					double dStart, double dEnd,
					double dBig, double dSmall,
					double dCur, double dStep,
					int& nWay, double& dSet);

	private:
		ZoomIntent	m_Intent;

		double		m_dBigZoom;
		double		m_dSmallZoom;
		double		m_dCurZoom;
		double		m_dStepZoom;
		int		m_nWay;

		double		m_dBigZoomX;
		double		m_dSmallZoomX;
		double		m_dCurZoomX;
		double		m_dStepZoomX;
		int		m_nWayX;

		double		m_dBigZoomY;
		double		m_dSmallZoomY;
		double		m_dCurZoomY;
		double		m_dStepZoomY;
		int		m_nWayY;

		UINT		m_nTimes;
	};
}

#endif